home *** CD-ROM | disk | FTP | other *** search
- /*
- File: KeyboardModuleHeader.c
-
- Contains: Keyboard Module Header file
-
- Version: xxx put version here xxx
-
- Copyright: © 1997-1999 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <Types.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
-
- #include "KeyboardModule.h"
- #include "KeyboardModuleVersion.h"
-
- static OSStatus KeyboardModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
- static OSStatus KeyboardModuleFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
- static OSStatus KeyboardInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
- static OSStatus KeyboardNotifyProc(UInt32 notification, void *pointer, UInt32 refcon);
-
- extern usbKeyboardPBStruct myKeyboardPB;
- extern usbKeyboardPBStruct shimKeyboardPB;
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature,
- kInitialUSBDriverDescriptor,
-
- // Device Info
- 0, // vendor = not device specific
- 0, // product = not device specific
- 0, // version of product = not device specific
- kUSBKeyboardInterfaceProtocol, // protocol = not device specific
-
- // Interface Info (* I don't think this would always be required...*)
- 0, // Configuration Value
- 0, // Interface Number
- kUSBHIDInterfaceClass, // Interface Class
- kUSBBootInterfaceSubClass, // Interface SubClass
- kUSBKeyboardInterfaceProtocol, // Interface Protocol
-
-
- // Driver Info
- kKeyboardModuleName kKBDStringVersShort, // Driver name for Name Registry
- kUSBHIDInterfaceClass, // Device Class (from USBDeviceDefines.h)
- kUSBBootInterfaceSubClass, // Device Subclass
- kKBDHexMajorVers,
- kKBDHexMinorVers,
- kKBDCurrentRelease,
- kKBDReleaseStage, // version of driver
-
- // Driver Loading Info
- kUSBProtocolMustMatch // Flags
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- 0, // Hardware Validation Procedure
- KeyboardModuleInitialize, // Initialization Procedure
- KeyboardInterfaceInitialize, // Interface Initialization Procedure
- KeyboardModuleFinalize, // Finalization Procedure
- KeyboardNotifyProc, // Driver Notification Procedure
- };
-
-
- // Initialization function
- // Called upon load by Expert
- static OSStatus KeyboardModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
- #pragma unused (pDesc)
- USBExpertStatus(device, kKeyboardModuleName": Entered via KeyboardModuleInitialize", device);
- return (OSStatus)noErr;
- }
-
- // Interface Initialization Initialization function
- // Called upon load by Expert
- static OSStatus KeyboardInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
- {
- InterfaceEntry(interfacenum, pInterface, pDesc, device);
- return (OSStatus)noErr;
- }
-
- static OSStatus KeyboardNotifyProc(UInt32 notification, void *pointer, UInt32 refcon)
- {
- #pragma unused (pointer)
- #pragma unused (refcon)
-
- OSStatus status = noErr;
-
- switch (notification)
- {
- case kNotifyExpertTerminating: // TCC <USB18>
- return(noErr);
- break;
- case kNotifyDriverBeingRemoved:
- shimKeyboardPB.driverRemovalPending = true;
- myKeyboardPB.driverRemovalPending = true;
-
- shimKeyboardPB.keyboardReady = false;
- myKeyboardPB.keyboardReady = false;
-
- USBExpertStatus(myKeyboardPB.interfaceRef, kKeyboardModuleName": Notification that driver removal is pending...", notification);
-
- if ((shimKeyboardPB.pb.usbRefcon & kCompletionPending) ||
- (myKeyboardPB.pb.usbRefcon & kCompletionPending))
- {
- if (shimKeyboardPB.pb.usbRefcon & kCompletionPending)
- {
- USBExpertStatus(myKeyboardPB.interfaceRef, kKeyboardModuleName": Waiting for set LEDs transaction to complete", myKeyboardPB.pb.usbRefcon);
- }
-
- if (myKeyboardPB.pb.usbRefcon & kCompletionPending)
- {
- USBExpertStatus(myKeyboardPB.interfaceRef, kKeyboardModuleName": Waiting for normal transaction to complete", myKeyboardPB.pb.usbRefcon);
- }
-
- if (myKeyboardPB.pipeRef)
- {
- USBExpertStatus(myKeyboardPB.interfaceRef, kKeyboardModuleName": Aborting interrupt pipe", myKeyboardPB.pipeRef);
- if (USBAbortPipeByReference(myKeyboardPB.pipeRef) != noErr){
- myKeyboardPB.pb.usbRefcon &= ~kCompletionPending; // don't expect the completion to be called either
- }
- myKeyboardPB.intPipeAborted = true;
- myKeyboardPB.pipeRef = nil;
- }
- status = kUSBDeviceBusy;
- }
- break;
-
- default:
- break;
- } // switch
-
-
- return(status);
- }
-
- // Termination function
- // Called by Expert when driver is being shut down
- static OSStatus KeyboardModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
- {
- #pragma unused (pDesc)
-
- USBExpertStatus(theDeviceRef, kKeyboardModuleName": Finalize", theDeviceRef);
- return (OSStatus)noErr;
- }
-
-